﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BusinessObjects.BO_GetObjects;
using LibraryO2S;
using BusinessObjects;

public partial class controls_admin_Help : Pages_Base
{
    protected void Page_Load(object sender, EventArgs e)
    {
        base.removeHGC(divMessage);
        loadSrcRpt();
    }
    private void loadSrcRpt()
    {
        try
        {
            base.OpenConnection();
            DataTable objDT = BO_HelpCategories.SearchByParent(0);
            if (objDT.Rows.Count > 0)
            {
                rptHelp.DataSource = objDT;
                rptHelp.DataBind();
            }
            else
            {
                divMessage.InnerHtml = O2S_Message.Notice("Cảnh Báo", "Chưa có dữ liệu");
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
        finally { base.CloseConnection(); }
    }
    protected string loadChild(int category_id)
    {
        try
        {
            base.OpenConnection();
            DataTable dt = BO_HelpCategories.SearchByParent(category_id);
            string strReturn = "<div class=\"adv-box-content\"><ul><li>";

            foreach (DataRow row in dt.Rows)
            {
                strReturn += "<div class=\"adv-box-content\"><ul class=\"circle\"><li>";
                strReturn += "<a href=\"Default.aspx?module=HelpContent&id=" + row["category_id"].ToString() + "\">" + row["category_name"].ToString() + "</a>";
                strReturn += loadChild(Convert.ToInt32(row["category_id"].ToString()));
                strReturn += "</li></ul></div>";
            }
            if (dt.Rows.Count == 0)
            {
                return "";
            }
            strReturn += "</li></ul></div>";
            return strReturn;
        }
        catch { return null; }
        finally { base.CloseConnection(); }
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        //Response.Redirect("Default.aspx?module=searchresult&search=" + txtSearch.Value.Trim());
    }
}
